# 配置 MongoDB 生产环境安全设置

# 启用认证并创建管理员用户
mongo admin --eval "
db.createUser({
  user: 'admin',
  pwd: 'your-strong-admin-password',
  roles: [
    { role: 'userAdminAnyDatabase', db: 'admin' },
    { role: 'readWriteAnyDatabase', db: 'admin' }
  ]
});
"

# 为应用创建专用用户
mongo web-notes-prod --eval "
db.createUser({
  user: 'webnotesuser',
  pwd: 'your-strong-app-password',
  roles: [
    { role: 'readWrite', db: 'web-notes-prod' }
  ]
});
"

echo "MongoDB 用户创建完成"
echo "请更新 .env 文件中的 MONGODB_URI:"
echo "MONGODB_URI=mongodb://webnotesuser:your-strong-app-password@localhost:27017/web-notes-prod"